package DSENS;




/**
 *
 * @author Lebby,teeteto
 */

public class Event {
    private int genNodeID;
    private int rcvNodeID;
    private String eventType;
    private int distance;
    private static int eventidentifier=-1;
    private final int ID;
    private Message message;
    private TimeLine timeline;
    private int slot;

    //Constructor having unique global TimeLine reference
    public Event(int gn, int rn,String et, int d, Message message){
        this.genNodeID=gn;
        this.rcvNodeID=rn;
        this.eventType=et;
        this.distance=d;
        this.message = message;
        this.setTimeline(GlobalInfo.TIMELINE);
        Event.eventidentifier ++;
        this.ID= Event.eventidentifier;
        this.slot = this.timeline.getTs()+this.distance;
    }

//Constructor without a global TimeLine reference
public Event(int gn, int rn,String et, int d, Message message, TimeLine tl){
        this.genNodeID=gn;
        this.rcvNodeID=rn;
        this.eventType=et;
        this.distance=d;
        this.message = message;
        this.setTimeline(tl);
        Event.eventidentifier ++;
        this.ID= Event.eventidentifier;
        this.slot = this.timeline.getTs()+this.distance;
    }

    public void printEvent(){
        System.out.print("Event #"+this.ID+" node #"+this.genNodeID+" -> node #"+this.rcvNodeID+" Type -"+this.eventType+"-\n");
    }
    public void printEvent(String comment){
        System.out.print("Event #"+this.ID+" node #"+this.genNodeID+" -> node #"+this.rcvNodeID+" Type -"+this.eventType+"- : "+comment+"\n");
    }
    public int getSlot() {
        return slot;
    }

    public void setSlot(int slot) {
        this.slot = slot;
    }

    public Message getMessage() {
        return this.message;
    }

    public void setMessage(Message message) {
        this.message = message;
    }

    public TimeLine getTimeline() {
        return timeline;
    }

    private void setTimeline(TimeLine timeline) {
        this.timeline = timeline;
    }

    /**
     *
     * @return
     */
    public int getgenNodeID(){
        return this.genNodeID;
    }
    /**
     *
     * @param id
     */
    public void setgenNodeID(int id){
        this.genNodeID = id;
    }
    /**
     *
     * @return
     */
    public int getrcvNodeID(){
        return this.rcvNodeID;
    }
    /**
     *
     * @param id
     */
    public void setrcvNodeID(int id){
        this.rcvNodeID = id;
    }
    /**
     *
     * @return
     */
    public String geteventType(){
        return this.eventType;
    }
    /**
     *
     * @param et
     */
    public void seteventType(String et){
        this.eventType = et;
    }
    /**
     *
     * @return
     */
    public int getDistance(){
        return this.distance;
    }
    /**
     *
     * @param d
     */
    public void setDistance(int d){
        this.distance = d;
    }

    public int getID() {
        return this.ID;
    }



}

